{extend name="base" /}

{block name="body"}

{php}
  use constant\OrderStatus;
  use constant\PayStatus;
  use constant\ShippingStatus;
  use constant\PayNameStatus;
{/php}

<section class="content-header">
  <h1>
    订单列表
    <small>订单 管理</small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="{:url('admin/index/index')}"><i class="fa fa-dashboard"></i> Home</a></li>
    <li class="active">订单列表</li>
  </ol>
</section>

<section class="content">
  <!-- 筛选框 -->
  <div class="box box-info">
    <div class="box-header with-border">
      <h3 class="box-title">筛选</h3>
    </div>

    <form class="form-horizontal" id="search-form">
      <div class="box-body">

        <div class="form-group">
          <label for="inputEmail3" class="col-sm-1 control-label">订单状态</label>
          <div class="col-sm-2">
            <select class="form-control select2" name="order_status" >
              <option value="">全部</option>
              <option value="1" {$order_status == 1? 'selected' : ''}>待确认</option>
              <option value="2" {$order_status == 2? 'selected' : ''}>已确认</option>
              <option value="3" {$order_status == 3? 'selected' : ''}>已收货</option>
              <option value="4" {$order_status == 4? 'selected' : ''}>已取消</option>
              <option value="5" {$order_status == 5? 'selected' : ''}>已完成</option>
            </select>
          </div>

          <label for="inputEmail3" class="col-sm-1 control-label">发货状态</label>
          <div class="col-sm-2">
            <select class="form-control select2" name="shipping_status" >
              <option value="">全部</option>
              <option value="1" {$shipping_status == 1? 'selected' : ''}>未发货</option>
              <option value="2" {$shipping_status == 2? 'selected' : ''}>已发货</option>
            </select>
          </div>

          <label for="inputEmail3" class="col-sm-1 control-label">创建时间</label>

          <div class="input-group col-sm-4">
            <div class="input-group-addon">
              <i class="fa fa-calendar"></i>
            </div>
            <input type="text" name="start" value="{$start}" class="form-control pull-right datepicker-style" placeholder="开始时间">

            <div class="input-group-addon">
              <i class="fa fa-calendar"></i>
            </div>
            <input type="text" name="stop" value="{$stop}" class="form-control pull-right datepicker-style" placeholder="结束时间">
          </div>
        </div>

        <div class="form-group">
          <label for="input3" class="col-sm-1 control-label">订单号</label>

          <div class="col-sm-3">
            <input type="text" name="order_sn" value="{$order_sn}" class="form-control" placeholder="请输入订单号">
          </div>

          <label for="inputEmail3" class="col-sm-1 control-label">支付状态</label>
          <div class="col-sm-2">
            <select class="form-control select2" name="pay_status" >
              <option value="">全部</option>
              <option value="1" {$pay_status == 1? 'selected' : ''}>未支付</option>
              <option value="2" {$pay_status == 2? 'selected' : ''}>已支付</option>
            </select>
          </div>

          <label for="inputEmail3" class="col-sm-1 control-label">支付方式</label>
          <div class="col-sm-2">
            <select class="form-control select2" name="pay_name" >
              <option value="">全部</option>
              <option value="cod_pay" {$pay_name == 'cod_pay'? 'selected' : ''}>货到付款</option>
              <option value="wx_pay" {$pay_name == 'wx_pay'? 'selected' : ''}>微信支付</option>
              <option value="ali_pay" {$pay_name == 'ali_pay'? 'selected' : ''}>支付宝支付</option>
              <option value="online_pay" {$pay_name == 'online_pay'? 'selected' : ''}>银联支付</option>
            </select>
          </div>
        </div>

      </div>

      <div class="box-footer">
        <div class="row">
          <div class="col-md-1 col-md-offset-10">
            <button type="reset" class="btn btn-default btn-reset">重置</button>
          </div>
          <div class="">
            <button type="submit" class="btn btn-info">搜索</button>
          </div>
        </div>
      </div>

    </form>
  </div>


  <!-- 列表 -->
  <div class="row">
    <div class="col-xs-12">

      <div class="box">

        <div class="box-header">

          <a href="javascript:;" data-url="{:url('exportOrder')}" down-url="{:isSsl()?'https':'http'}://{$_SERVER.HTTP_HOST}" data-where="{$_where}"  title="导出订单" class="btn btn-info btn-social-icon export-btn"><i class="fa fa-cloud-download"></i></a>

          <a href="javascript:location=location" title="刷新" class="btn btn-default btn-social-icon"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></a>
          <b style="color:#444">&nbsp;&nbsp;&nbsp;订单总数：{$info->total()}</b>
        </div>

        <div class="box-body table-responsive no-padding">
          <table class="table table-hover">
            <tr>
              <th>订单号</th>
              <th>总金额</th>
              <th>订单状态</th>
              <th>支付状态</th>
              <th>发货状态</th>
              <th>支付方式</th>
              <th>创建时间</th>
              <th>操作</th>
            </tr>
            {volist name="info" id="v"}
            <tr class="text-c">
              <td>{$v.order_sn}</td>
              <td>{$v.total_amount}</td>
              <td>{:OrderStatus::$cn[$v.order_status]}</td>
              <td>{:PayStatus::$cn[$v.pay_status]}</td>
              <td>{:ShippingStatus::$cn[$v.shipping_status]}</td>
              <td>{$v.pay_name|default="--"}</td>
              <td>{$v.add_time|date="Y-m-d H:i:s",###}</td>
              <td>
                <a href="javascript:;" title="订单详情" class="btn btn-xs btn-danger btn-social-icon details-btn" data-id="{$v.id}" data-url="{:url('detail')}"><i class="fa fa-list"></i></a>

                {if condition="$v.shipping_status eq 1 && $v.order_status eq 2 && $v.shipping_status eq 1"}
                  <a href="javascript:;" title="发货" data-id="{$v.id}" data-url="{:url('deliverGoodsPage')}" proc-url="{:url('deliverGoodsProc')}" class="btn btn-xs btn-info btn-social-icon deliver-btn"><i class="fa fa-paper-plane-o"></i></a>
                {/if}

                {if condition="$v.pay_status eq 1"}
                  <a href="javascript:;" title="删除订单" data-id="{$v.id}" data-url="{:url('delete')}" class="btn btn-xs btn-danger btn-social-icon delete-btn"><i class="fa fa-trash-o"></i></a>
                {/if}
              </td>
            </tr>
            {/volist}
          </table>
        </div>

        <div class="box-footer clearfix">
            {$info->render()}
        </div>
      </div>

    </div>
  </div>


</section>

{/block}

{block name="script"}
<script type="text/javascript" src="__AJS__/order/index.js"></script>
{/block}